package com.learn.mapper;

import com.learn.pojo.Emp;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface EmpMapper {
    @Delete("delete from emp where id = #{id}")
    int deleteByPrimaryKey(Integer id);

    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into emp(username,password,name,gender,image,job,entrydate,dept_id,create_time,update_time) " +
            "values(#{username},#{password},#{name},#{gender},#{image},#{job},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    void insert(Emp emp);

//    @Update("update emp set username=#{username},password=#{password},name=#{name},gender=#{gender},image=#{image},job=#{job},entrydate=#{entryDate},dept_id=#{deptId},update_time=#{updateTime} where id=#{id}")
    void update(Emp emp);

    @Select("select * from emp where id = #{id}")
    Emp selectById(Integer id);

//    @Select("select * from emp where name like '%${name}%' and gender = #{gender} and entrydate between #{begin} and #{end} order by update_time desc")
//    List<Emp> list(String name, Short gender, LocalDate begin, LocalDate end);

//    @Select("select * from emp where name like concat('%',#{name},'%') and gender = #{gender} and entrydate between #{begin} and #{end} order by update_time desc")
    List<Emp> list(String name, Short gender, LocalDate begin, LocalDate end);

    void deleteByIds(Integer[] ids);
}
